home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DRIVES.SWG / 0063_Detecting CDROM Drives.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  4KB  |  102 lines

  1. {
  2. From: GREG VIGNEAULT
  3. Subj: Extended drives (CD-ROM)
  4. ---------------------------------------------------------------------------
  5.  In a message with STEVE ROGERS...
  6. SR>PN>  Is it acceptable and safe for the hardware to attempt to write
  7. SR>  >  a test file to a CD-Rom drive? I would do this to find out that
  8. SR>  I tried this a few years ago and just got a write error. Should be
  9. SR>  safe enough.
  10.  
  11. LD>Although... would you not get the same result as you would on a
  12.   >write-protected disk, or a full disk, or one where the "test"
  13.   >file name is unacceptable?
  14.  
  15.  Hi Lou,
  16.  
  17.  I haven't been following this thread, so I don't know what all has
  18.  been said. I don't have a CD-ROM but I'll toss in some of the info
  19.  that I'm aware of...
  20.  
  21.  Here is TP source that can detect if one or more CD-ROM is present
  22.  in a PC system, and the drive letter of the first CD-ROM. It tries
  23.  to find if the Microsoft CD-ROM Extension (MSCDEX) is installed...
  24. }
  25.  
  26. (*******************************************************************)
  27. PROGRAM CDROM;                    { compiler: Turbo Pascal 4.0+     }
  28.                                   { Jan.07.94 Greg Vigneault        }
  29.  
  30. USES  Dos;                        { import  Intr, Registers         }
  31. VAR   DrvName   : CHAR;           { first extended drive (A: to Z:) }
  32.       DrvCount   : WORD;          { number of extended drives       }
  33.       IsMSCDEX,                   { TRUE if MSCDEX is installed     }
  34.       IsCDROM   : BOOLEAN;        { TRUE if extended drive is CDROM }
  35.  
  36. (*-----------------------------------------------------------------*)
  37. { Detect if/how-many extended drives (CD-ROMs) are in system ...    }
  38.  
  39. PROCEDURE CD_ROMdat ( VAR DrvCount  : WORD;     { total ext. drives }
  40.                       VAR FirstDrv  : CHAR;     { first ext. drv    }
  41.                       VAR IsMSCDEX  : BOOLEAN;  { MSCDEX found?     }
  42.                       VAR IsCDROM   : BOOLEAN); { is CD-ROM?        }
  43.   VAR Reg : Registers;            { to access 8086 CPU registers    }
  44.   BEGIN {CD_ROMdat}
  45.                                   { initialize the VARs...          }
  46.       FirstDrv  := #0;            { assume no extension drives      }
  47.       IsMSCDEX  := FALSE;         { assume MSCDEX not installed     }
  48.       IsCDROM   := FALSE;         { assume drive isn't a CD-ROM     }
  49.       Reg.AX := $1500;            { fn: check if CD-ROM is present  }
  50.       Reg.BX := 0;                    { clear BX                    }
  51.       Intr ($2F, Reg);                { invoke MSCDEX               }
  52.       DrvCount := Reg.BX;             { count of extended drives    }
  53.       IF (DrvCount = 0) THEN EXIT;    { abort if no extended drive  }
  54.       FirstDrv := CHR (Reg.CX + 65);  { first drive IN ['A'..'Z']   }
  55.       Reg.AX := $150B;                { fn: CD-ROM drive check      }
  56.       Reg.BX := 0;                    { Reg.CX already has drive #  }
  57.       Intr ($2F, Reg);                { call the CD-ROM services    }
  58.       IF (Reg.BX <> $ADAD) THEN EXIT; { MSCDEX isn't installed      }
  59.       IsMSCDEX := TRUE;               { MSCDEX is installed         }
  60.       IF (Reg.AX = 0) THEN EXIT;      { ext. drive isn't a CD-ROM   }
  61.       IsCDROM := TRUE;                { extended is a CD-ROM        }
  62.   END {CD_ROMdat};                    { END PROCEDURE DC_ROMdat     }
  63.  
  64. (*-----------------------------------------------------------------*)
  65. BEGIN {PROGRAM CDROM}
  66.  
  67.   CD_ROMdat (DrvCount, DrvName, IsMSCDEX, IsCDROM);
  68.   WriteLn;
  69.  
  70.   IF (DrvCount <> 0) THEN BEGIN
  71.     IF IsMSCDEX THEN WriteLn ('MSCDEX is installed');
  72.     Write ('Extended drive(s) detected');
  73.     IF IsCDROM THEN Write (' (CD-ROM)');
  74.     WriteLn (' = ',DrvCount,' at ',DrvName,':');
  75.     END {IF DrvCount}
  76.   ELSE
  77.     WriteLn ('No extended drives (CD-ROMs) detected in system.');
  78.  
  79.   WriteLn;
  80.  
  81. END {CDROM}.
  82. (*******************************************************************)
  83.  
  84.  The familiar Int21h file i/o can be used for reading files on an
  85.  extended drive.  The MSCDEX also offers the following extended
  86.  functions...
  87.  
  88.       o Get CD-ROM Drive List
  89.       o Get Copyright Filename
  90.       o Get Abstract Filename
  91.       o Get Bibliographic Filename
  92.       o Read Volume Table of Contents
  93.       o Absolute Disk Read
  94.       o Absolute Disk Write
  95.       o Get CD-ROM Extensions Version
  96.       o Get CD-ROM Units
  97.       o Get or Set Volume Descriptor Preference
  98.       o Get Directory Entry
  99.       o Send Device Request
  100.  
  101.  Greg_
  102.